<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<p>This tests for a bug where centering two paragraphs would center the third.  Only the selected paragraphs should be selected.</p>
<div id="sample" contenteditable="true">foo<div id="end">bar<br>baz</div></div>
<div id="log"></div>
<script>
test(function() {
    var selection = window.getSelection();
    var sample = document.getElementById('sample');

    selection.collapse(sample, 0);
    selection.extend(document.getElementById('end'), 2);
    document.execCommand('justifyCenter');

    assert_equals(sample.innerHTML, '<div style=\"text-align: center;\">foo</div><div id=\"end\"><div style=\"text-align: center;\">bar</div><div style=\"text-align: center;\">baz</div></div>', 'innerHTML');
    assert_false(selection.isCollapsed, 'isCollapsed');
    assert_equals(selection.anchorNode, sample.firstChild.firstChild, 'anchorNode');
    assert_equals(selection.anchorOffset, 0, 'anchorOffset');
    assert_equals(selection.focusNode, sample.lastChild.lastChild, 'focusNode');
    assert_equals(selection.focusOffset, 0, 'focusOffset');
});
</script>
